package com.jsu.clubmanagementsystem.service.system;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jsu.clubmanagementsystem.common.PageQueryRequest;
import com.jsu.clubmanagementsystem.mapper.SystemAnnouncementMapper;
import com.jsu.clubmanagementsystem.model.entity.SystemAnnouncement;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 24753
* @description 针对表【system_announcement(系统公告)】的数据库操作Service实现
* @createDate 2025-05-13 17:19:16
*/
@Service
public class SystemAnnouncementServiceImpl extends ServiceImpl<SystemAnnouncementMapper, SystemAnnouncement>
        implements SystemAnnouncementService{
    @Resource
    private SystemAnnouncementMapper systemAnnouncementMapper;

    @Override
    public Page<SystemAnnouncement> getAll(PageQueryRequest page){
        String query=page.getQuery();
        QueryWrapper<SystemAnnouncement>  wrapper=new QueryWrapper<>();
        if(query!=null){
            wrapper.like("title",query);
        }
        Page<SystemAnnouncement> system=new Page<>(page.getCurrent(),page.getPageSize());
        List<SystemAnnouncement> systemAnnouncements = systemAnnouncementMapper.selectAll(system, wrapper);
        system.setRecords(systemAnnouncements);
        return system;
    }

    @Override
    public void deleteAll(List<Long> id){
        systemAnnouncementMapper.deleteBatchIds(id);
    }
}




